
export { };
// 2.用es5的语法写单例模式
function Window() { };
Window.prototype.hello = function () {
  console.log('hello--我是es5！！')
};
Window.getInstance2 = (function () {
  let instance2: Window;
  return function () {
    if (!instance2) {
      console.log('2 没有走缓存');
      return instance2 = new (Window as any)()
    };
    console.log('2 走缓存');
    return instance2
  };
})();
//2 测试单例
// new (Window as any)().hello();
let w11 = Window.getInstance2();
let w22 = Window.getInstance2();
console.log(`2 两个实例是否一样${w11 == w22}`)

